package com.aaa.controller;


import com.aaa.entity.Video;
import com.aaa.mapper.VideoMapper;
import com.aaa.service.impl.VideoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.rmi.runtime.Log;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-03
 */
@RestController
@Api(tags = "视频接口")
@CrossOrigin
@RequestMapping("/video")
public class VideoController {
    @Autowired
    VideoServiceImpl videoServiceimpl;
    //查询用户作品

    /**
     * 查询用户自己或者是其他人的作品信息
     *
     * @param uid 当查看自己的作品时只传入 uid
     * @param id  当查看其他人的作品的时候传入   自己(uid)的id  和查看人（id）的 id 未登录自己的（uid）传入空值 只传入id
     * @return
     */
    @ApiOperation("查询用户作品")
    @RequestMapping(value = "seleworks",method = RequestMethod.POST)
    public List<Video> userid(@ApiParam("用户自己id") Integer uid,@ApiParam("被查看者id,查看自己不传") Integer id){
        return videoServiceimpl.userid(uid,id);
    }


    //查询用户的赞作品

    /**
     * 查询用户的所有赞作品
     * @param uid
     * @return
     */
    @ApiOperation("用户赞过的作品")
    @RequestMapping(value = "likevideo",method = RequestMethod.POST)
    public List<Map<String,Object>> likevideo(@ApiParam("用户id") Integer uid){
        return videoServiceimpl.likevideo(uid);
    }


    /***
     * 查询某一个用户的所有关注人的所有作品
     * @param uid
     * @return
     */
    @ApiOperation("查询关注作品")
    @RequestMapping(value = "attenvideo",method = RequestMethod.POST)
    public List<Map<String,Object>> attenvideo(@ApiParam("用户id") Integer uid){
        return videoServiceimpl.attenvideo(uid);
    }


    @SneakyThrows
    @ApiOperation("上传作品")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public boolean add(@RequestPart("video") MultipartFile video,Integer uid,String introduce,Integer state){
    return videoServiceimpl.add(video,uid,introduce,state);
    }

    @ApiOperation("推荐作品")
    @RequestMapping(value = "recomment",method = RequestMethod.POST)
    public List<Map<String,Object>> recomment(@ApiParam("用户id未登录传null") Integer uid,Integer page){
        return videoServiceimpl.recomment(uid,page);
    }

}
